package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"net/http"
)

func main() {
	request, err := http.NewRequest("GET", "http://localhost:8888", nil)
	if err != nil {
		log.Fatal(err)
	}

	http_client := &http.Client{}
	response, err := http_client.Do(request)
	if err != nil {
		log.Fatal(err)
	}

	defer response.Body.Close()
	reader := bufio.NewReader(response.Body)
	msg := make([]byte, 2048)
	for {
		readN, err := response.Body.Read(msg)
		if readN == 0 {
			continue
		}
		msg = msg[:readN]

		if readN > 0 {
			msg = msg[readN]
		}
		line, err := reader.ReadBytes('\n')
		if len(line) > 0 {
			fmt.Print(string(line))
		}
		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
	}

}
